package edu.cuit.avatar.inherit;

/**
 * @author <a href="mailto:1020zhaodan@163.com">Adan</a>
 * @version 1.0
 * @date 2025/7/9 15:41
 */
public class GeometricTest {
    public static void main(String[] args) {
        Geometric circle = new Circle(5, "red", true);
        //向下转型(类型强转)
        if(circle instanceof Circle c) {
            //Circle c = (Circle) circle;
            System.out.println("area:" + c.getArea());
        }
        System.out.println(circle.toString());

        Geometric rectangle = new Rectangle(5, 4);
        System.out.println(rectangle.toString());

        if(circle instanceof Rectangle r) {
            //Rectangle r = (Rectangle) circle; //ClassCastException
        }
    }
}
